
#ifndef __DRV_TIMER_H__
#define __DRV_TIMER_H__
#include <stdint.h>
#include <stdbool.h>
#include "driver/driver_common.h"
#include "gd32f4xx_timer.h"

#define DRV_TIMER_INSTANCES_NUMBER 4

typedef struct timer_cfg_tag
{
    uint32_t timer_periph;
    rcu_periph_enum timer_rcu;
    uint8_t nvic_irq;
    uint8_t nvic_irq_pre_priority;
    uint8_t nvic_irq_sub_priority;
} timer_cfg_t;

typedef struct
{
    /* The module index associated with the object*/
    SYS_MODULE_ID moduleId;

    /* Flag to indicate this object is in use  */
    bool inUse;

} DRV_TIMER_OBJ;

SYS_MODULE_OBJ DRV_TIMER_Initialize(const SYS_MODULE_INDEX drvIndex,
                                    const SYS_MODULE_INIT *const init);
int DRV_TIMER_Enable(const SYS_MODULE_INDEX drvIndex);
int DRV_TIMER_Disable(const SYS_MODULE_INDEX drvIndex);
int DRV_TIMER_SetPeriod(const SYS_MODULE_INDEX drvIndex, uint32_t us);

#endif
